package com.example.fx.utils

import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.example.fx.R

/**
 * 图片加载框架工具类--加载普通、圆形、圆角
 */
class GlideUtils {
    companion object{
        fun loadImage(context: Context,url:String,imageView: ImageView){
            Glide.with(context)
                .load(url)
                .error(R.drawable.ic_launcher_background)
                .skipMemoryCache(false)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .into(imageView)
        }
        fun loadCircleImage(context: Context,url:String,imageView: ImageView){
            Glide.with(context)
                .load(url)
                .error(R.drawable.ic_launcher_background)
                .skipMemoryCache(false)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .circleCrop()
                .into(imageView)
        }
        fun loadCornerImage(context: Context,url:String,imageView: ImageView){
            Glide.with(context)
                .load(url)
                .error(R.drawable.ic_launcher_background)
                .skipMemoryCache(false)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .transform(CenterCrop(),RoundedCorners(30))
                .into(imageView)
        }
    }
}